/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package restAPI;

import internalAPI.Query;
import org.restlet.Response;
import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.restlet.resource.Delete;
import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;

/**
 *
 * @author ferco
 * Class for representation of general resource of our database
 */
public class Resource extends ServerResource{
    
    @Get
    public void getXML() { 
        
        String message = RestAPI.executor.processQuery(new Query());      
       
        Response.getCurrent().setEntity(message, MediaType.TEXT_XML);        
    }
    
    @Post
    public void postXML(String data) {                     
        RestAPI.executor.storePlace(data);         
        Response.getCurrent().setStatus(Status.SUCCESS_OK); 
    }
    
    @Put
    public void putXML(){
        Response.getCurrent().setStatus(Status.SERVER_ERROR_SERVICE_UNAVAILABLE);    
    }
    
    @Delete
     public void deleteXML() {
        Response.getCurrent().setStatus(Status.SERVER_ERROR_SERVICE_UNAVAILABLE);
    }
    
}
